#delimit;
capture log close;
set more off;
pause on;
clear all;
set scheme plottig;

cap cd "/Users/deandulay/Dropbox/Myanmar_JOP_EGI_replication";
cap cd "C:\Users\ejm5\Dropbox\Myanmar_JOP_EGI_replication";
use  "data\20220606_mbei_panel_working.dta", clear;

******************************************************************************************************************************************************/
/*****Appendix E1: Balance Table*****/
#delimit;
svy: reg weighted workshop unidirectional if year==2018 , nocons;
outreg2 using "tables\TableE1", tdec(3) bdec(3) noaster replace;
svy: reg weighted workshop  if year==2018 ;
outreg2 using "tables\TableE1", tdec(3) bdec(3) noaster pvalue;
foreach x in  weighted unweighted subindex1_final subindex2_final subindex3_final subindex4_final subindex5_final subindex6_final subindex7_final subindex8_final subindex9_final subindex10_final university_grad q19 years_firm bamar equity_above_500 q22 t_q57_3 manufacturing_firm {;
svy: reg `x' workshop unidirectional if year==2018 , nocons;
outreg2 using "tables\TableE1", tdec(3) bdec(3) noaster ;
svy: reg `x' workshop  if year==2018 ;
outreg2 using "tables\TableE1", tdec(3) bdec(3) noaster pvalue;
};

#delimit;
preserve;
#delimit;
collapse workshop unidirectional surface_area pop_total literacy_total pop_density gdp_cons_2018 if year==2018, by(p_code);
merge m:1 p_code using "data\NLD_vote.dta";
foreach x in  surface_area pop_total literacy_total pop_density gdp_cons_2018 NLD_2015_vote   {;
reg `x' workshop unidirectional  , nocons;
outreg2 using "tables\TableE1", tdec(3) bdec(3) noaster;
reg `x' workshop  ;
outreg2 using "tables\TableE1", tdec(3) bdec(3) noaster pvalue;
};
outreg2 using "tables\TableE1", tdec(3) bdec(3) pvalue excel;
restore;

/******************************************************************************************************************************************************/
/*Figure 5 Change in Overall Core MBEI Scores Between Facilitation and Non-Facilitation Groups*/
#delimit;
cibar weighted [aweight=weight_township], barcolor(gs4 navy) over1(workshop) over2(year) graphopts(xlab(, labsize(small)) ylab(50(1)65, labsize(small)) legend(rows(2) size(small) position(10) ring(0) label(1 "Facilitation") label(2 "No Facilitation")) ytitle("Score", size(medium) margin(medium)) scheme(economist) yscale(alt) title(" Weighted Core MBEI", size(medium) margin(medsmall)));
graph save "figures\Figure5_a.gph", replace;

cibar unweighted [aweight=weight_township], barcolor(gs4 navy) over1(workshop) over2(year) graphopts(xlab(, labsize(small)) ylab(50(1)70, labsize(small)) legend(off) ytitle("Score", size(medium) margin(medium))  scheme(economist) yscale(alt)  title("Unweighted Core MBEI", size(medium) margin(medsmall)));
graph save "figures\Figure5_b.gph", replace;

graph combine "figures\Figure5_a.gph" "figures\Figure5_b.gph", xcommon ycommon imargin(tiny)  scheme(economist) note("Range Bars=95% Confidence Intervals", size(tiny) position(7));
graph save "figures\Figure5.gph", replace;
graph export "figures\Figure5.pdf", as(pdf) replace;


/*******************************************************************************************************/
/*Table 3: Table 3 Facilitation Generates Sizable Improvements on Unweighted Core MBEI Index*/
#delimit;
svy: reg unweighted i.year##i.workshop;
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^) replace;

#delimit;
svy: reg unweighted i.year##i.workshop i.capital i.state_region;
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg unweighted i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg unweighted i.year##i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg unweighted i.year##i.workshop,  cluster(township);
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted i.year##i.workshop i.capital , absorb(state_region) cluster(township);
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region) cluster(township);
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg unweighted i.year##i.workshop  literacy surface_area lag if capital==0, absorb(state_region) cluster(township);
outreg2 using "tables\Table3", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;


/************************************************************************************************************************/
/*Robust to using probability weights instead of suvrey weights*/
#delimit;
reg unweighted i.year##i.workshop [pweight=weight_township], cluster(township);
areg unweighted i.year##i.workshop i.capital literacy surface_area lag  [pweight=weight_township], absorb(state_region) cluster(township);

/************************************************************************************************************************/
/*Table 4 Facilitation Only Effective in Decentralized Agencies*/
#delimit;
svy: reg DAO_indicators_final i.year##i.workshop;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^) replace;

#delimit;
svy: reg DAO_indicators_final i.year##i.workshop i.capital i.state_region;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg DAO_indicators_final i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg DAO_indicators_final i.year##i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

#delimit;
svy: reg GAD_indicators_final i.year##i.workshop;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^);

#delimit;
svy: reg GAD_indicators_final i.year##i.workshop i.capital i.state_region;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg GAD_indicators_final i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg GAD_indicators_final i.year##i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\Table4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

/**********************************************************************************************************************/